package com.ybwh.springboot2.enabled.selector;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;


@Slf4j
public class MyImportSelector implements ImportSelector {

    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Set<String> annotationTypes = importingClassMetadata.getAnnotationTypes();
        Iterator<String> zClasses = annotationTypes.iterator();
        while (zClasses.hasNext()) {
            String type = zClasses.next();
            if (type.equals(EnableSelector.class.getName())) {
                Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(EnableSelector.class.getName());
                log.info("------------------------{}",annotationAttributes);
            }
        }



        //返回的bean
        return new String[]{MyBean.class.getName()};
    }
}